home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /***************************************************************************
- *
- * BZ - Multiplayer tank game.
- *
- * $Id: bzbase.c,v 1.5 1993/08/11 19:45:43 adele Exp $
- *
- * Chris Fouts - Silicon Graphics, Inc.
- * October, 1991
- **************************************************************************/
- #include <stdio.h>
- #include <stdarg.h>
- #include <math.h>
- #include <malloc.h>
- #include <X11/Intrinsic.h>
- #include <Xm/Xm.h>
- #include <X11/Xirisw/GlxMDraw.h>
- #include <gl/gl.h>
- #include "bz.h"
- #include "bzscreen.h"
- #include "bzobjs.h"
- #include "bzbase.h"
-
- /* BEGIN PROTOTYPES -S bzbase.c */
- static void frame( float x01, float y01, float x02, float y02, Colorindex c0,
- Colorindex c1, float w ) ;
- static void init_bulletin( void ) ;
- static void show_number( int value, int places, float x, float y,
- Colorindex bg, Colorindex fg ) ;
- static void show_pick_tank_instructions( void ) ;
- static void show_something( float l, float b, float r, float t, int value,
- int places, Colorindex bg, Colorindex fg ) ;
- static void show_speed_util( float track, float l, float b, float r,
- float t ) ;
- static void title( int left, int bottom, int right, char *s ) ;
- /* END PROTOTYPES -S bzbase.c */
-
- static char *version_id = "$Id: bzbase.c,v 1.5 1993/08/11 19:45:43 adele Exp $" ;
-
-
- /*
- * Screen position variables.
- */
- DECLARE( MVIEW ) ;
- DECLARE( RADAR ) ;
- DECLARE( HEAD ) ;
- DECLARE( LOADM ) ;
- DECLARE( READY ) ;
- DECLARE( SCORE ) ;
- DECLARE( LIVES ) ;
- DECLARE( LEVEL ) ;
- DECLARE( NOPLY ) ;
- DECLARE( RIGHT ) ;
- DECLARE( LEFTT ) ;
- DECLARE( LOGOD ) ;
- DECLARE( MESGS ) ;
- DECLARE( OUTMS ) ;
- DECLARE( GROND ) ;
- DECLARE( MINES ) ;
- DECLARE( FLAGS ) ;
- extern float char_width ;
- extern float char_height ;
- extern float mv_w ;
- extern float mv_h ;
- extern float mv_m ;
- extern long screen_w, screen_h ;
-
- extern Boolean db_base ;
- extern Matrix id_mat ;
- Colorindex ramp0 ;
- Colorindex ramp1 ;
- Colorindex ramp2 ;
- Colorindex ramp3 ;
- Colorindex ramp4 ;
- extern Colorindex black ;
- extern Colorindex white ;
- extern Colorindex red ;
- extern Colorindex blue ;
- extern Colorindex green ;
- extern Colorindex yellow ;
-
- char msgs[POST_MSG_SIZE] ;
- int msg_count ;
- int msg_redraw = 0 ;
- int max_msg_lines ;
- typedef char BulletinLine[POST_MSG_SIZE+1] ;
- static BulletinLine *bulletin ;
- static Colorindex *bulletin_color ;
- static int bulletin_line = 1 ;
- static Colorindex current_bulletin_color ;
- extern unsigned int sending_msg ;
-
- GL_Object radar1 ;
- extern GL_Object digit[10][2] ;
- extern struct BzMember player[] ;
- extern struct BzNotice mail ;
-
- extern Window base_window ;
- extern Window radar_window ;
- extern Window radar_ol_window ;
-
- extern char *basename ;
- extern Boolean blue_flag_held ;
- extern GL_Object border ;
- extern float digit_sx ;
- extern float digit_sy ;
- extern Display *display ;
- extern GL_Object flag_homes ;
- extern float flag_x[] ;
- extern float flag_y[] ;
- extern Colorindex ground_color ;
- extern Boolean guiding ;
- extern int init_wait ;
- extern float left_track ;
- extern unsigned int level ;
- extern unsigned int lives ;
- extern long loading_missile ;
- extern unsigned int mine_left ;
- extern int need_to_show_msgs_vocal ;
- extern Boolean need_to_show_msgs ;
- extern Boolean never_have_flag ;
- extern GL_Object null_obj ;
- extern unsigned int number_players ;
- extern float obst_x[] ;
- extern float obst_y[] ;
- extern int ol_mode ;
- extern int perm_mine ;
- extern Boolean picking_tank ;
- extern Boolean red_flag_held ;
- extern float right_track ;
- extern int screen_mode ;
- extern long screen_w, screen_h ;
- extern Boolean show_flags ;
- extern Boolean solo ;
- extern GL_Object tank_logo[] ;
- extern Colorindex teamColor[] ;
- extern Widget toplevel ;
- extern float top_speed ;
- extern Boolean use_pups ;
- extern Boolean view_only ;
- extern float obst_y[] ;
- extern unsigned int number_players ;
- extern Colorindex teamColor[] ;
- extern int mine_status ;
- extern int perm_mine ;
- extern float mine_x ;
- extern float mine_y ;
- extern Boolean binoculars ;
- extern Arg wargs[] ;
- extern float zoom_factor ;
-
-
-
- void redraw_base_screen( void )
- {
- switch( screen_mode ) {
-
- case MAIN_SCREEN :
- case INTRO_PICK_SCREEN :
- init_screen() ;
- show_msgs( 0, 1 ) ;
- show_heading() ;
- show_speed() ;
- show_mine_status() ;
- show_flag_status() ;
- show_out_message() ;
- show_gun_status( loading_missile - 1 ) ;
- break ;
-
- case INTRO_SCREEN :
- draw_intro_screen() ;
- break ;
-
- }
- gflush() ;
- if( db_base ) swapbuffers();
- }
-
-
-
- void init_screen( void )
- {
- #if !defined( NETDEBUGGER )
- reshapeviewport() ;
- if( db_base ) frontbuffer(1);
- loadmatrix( id_mat ) ;
- ortho2( -0.5f, (float)screen_w-0.5f, -0.5f, (float)screen_h-0.5f ) ;
-
- color(ramp3);
- clear() ;
-
- bgnpolygon() ;
- color( ramp3 ) ;
- vertex2f( 0.f, 0.f) ;
- color( ramp2 ) ;
- vertex2f( 0.f, FVPMVIEW_B-FRAMEW ) ;
- color( ramp3 ) ;
- vertex2f( (float)screen_w, FVPMVIEW_B-FRAMEW ) ;
- endpolygon();
- bgnpolygon() ;
- color( ramp3);
- vertex2f( 0.f, 0.f ) ;
- color( ramp2);
- vertex2f( (float)screen_w, 0.f ) ;
- color( ramp3);
- vertex2f( (float)screen_w, FVPMVIEW_B-FRAMEW ) ;
- endpolygon();
-
- pushviewport() ;
- viewport( VPLOGOD_L, VPLOGOD_R, VPLOGOD_B, VPLOGOD_T ) ;
- ortho2( -5.f, 270.f, -15.f, 260.f ) ;
- color( ramp4 ) ;
- if( tank_logo[SELF] != null_obj ) {
- callobj( tank_logo[SELF] ) ;
- }
- else {
- rectf( 50.f, 50.f, 205.f, 205.f ) ;
- }
- ortho2( -15.f, 260.f, -5.f, 270.f ) ;
- color( black ) ;
- if( tank_logo[SELF] != null_obj ) {
- callobj( tank_logo[SELF] ) ;
- }
- else {
- rectf( 50.f, 50.f, 205.f, 205.f ) ;
- }
- ortho2( -10.f, 265.f, -10.f, 265.f ) ;
- if( player[SELF].team == RED_TEAM ) {
- color( red ) ;
- }
- else if( player[SELF].team == BLUE_TEAM ) {
- color( blue ) ;
- }
- else {
- color( green ) ;
- }
- if( tank_logo[SELF] != null_obj ) {
- callobj( tank_logo[SELF] ) ;
- }
- else {
- rectf( 50.f, 50.f, 205.f, 205.f ) ;
- }
- popviewport() ;
- ortho2( -0.5f, (float)screen_w-0.5f, -0.5f, (float)screen_h-0.5f ) ;
-
- frame( FVPMVIEW_L, FVPMVIEW_B, FVPMVIEW_R, FVPMVIEW_T,
- ramp0, ramp1, FRAMEW ) ;
- frame( FVPRADAR_L, FVPRADAR_B, FVPRADAR_R, FVPRADAR_T,
- ramp0, ramp1, FRAMEW ) ;
- frame( FVPHEAD_L, FVPHEAD_B, FVPHEAD_R, FVPHEAD_T,
- ramp0, ramp1, FRAMEW ) ;
- title( VPHEAD_L, VPHEAD_B, VPHEAD_R, "HEADING" ) ;
-
- frame( FVPLOADM_L, FVPLOADM_B, FVPLOADM_R, FVPLOADM_T,
- ramp0, ramp1, FRAMEW ) ;
- title( VPLOADM_L, VPLOADM_B, VPLOADM_R, "STATUS" ) ;
-
- frame( FVPREADY_L, FVPREADY_B, FVPREADY_R, FVPREADY_T,
- ramp0, ramp1 ,FRAMEW ) ;
- title( VPREADY_L, VPREADY_B, VPREADY_R, "STATUS" ) ;
-
- frame( FVPSCORE_L, FVPSCORE_B, FVPSCORE_R, FVPSCORE_T,
- ramp0, ramp1, FRAMEW ) ;
- title( VPSCORE_L, VPSCORE_B, VPSCORE_R, "SCORE" ) ;
-
- frame( FVPLIVES_L, FVPLIVES_B, FVPLIVES_R, FVPLIVES_T,
- ramp0, ramp1, FRAMEW ) ;
- title( VPLIVES_L, VPLIVES_B, VPLIVES_R, "LIVES" ) ;
-
- frame( FVPLEVEL_L, FVPLEVEL_B, FVPLEVEL_R, FVPLEVEL_T,
- ramp0, ramp1, FRAMEW ) ;
- title( VPLEVEL_L, VPLEVEL_B, VPLEVEL_R, solo ? "LEVEL" : "KILLS" ) ;
-
- frame( FVPNOPLY_L, FVPNOPLY_B, FVPNOPLY_R, FVPNOPLY_T,
- ramp0, ramp1, FRAMEW ) ;
- title( VPNOPLY_L, VPNOPLY_B, VPNOPLY_R, "PLAYERS" ) ;
-
- frame( FVPRIGHT_L, FVPRIGHT_B, FVPRIGHT_R, FVPRIGHT_T,
- ramp0, ramp1, FRAMEW ) ;
- title( VPRIGHT_L, VPRIGHT_B, VPRIGHT_R, "RIGHT" ) ;
-
- frame( FVPLEFTT_L, FVPLEFTT_B, FVPLEFTT_R, FVPLEFTT_T,
- ramp0, ramp1, FRAMEW ) ;
- title( VPLEFTT_L, VPLEFTT_B, VPLEFTT_R, "LEFT" ) ;
-
- frame( FVPMESGS_L, FVPMESGS_B, FVPMESGS_R, FVPMESGS_T,
- ramp0, ramp1, FRAMEW ) ;
- title( VPMESGS_L, VPMESGS_B, VPMESGS_R, "MESSAGES" ) ;
-
- if( !view_only ) {
- frame( FVPMINES_L, FVPMINES_B, FVPMINES_R, FVPMINES_T,
- ramp0, ramp1, FRAMEW ) ;
- title( VPMINES_L, VPMINES_B, VPMINES_R, "MINE" ) ;
- }
-
- if( !solo && !view_only ) {
- frame( FVPOUTMS_L, FVPOUTMS_B, FVPOUTMS_R, FVPOUTMS_T,
- ramp0, ramp1, FRAMEW ) ;
- title( VPOUTMS_L, VPOUTMS_B, VPOUTMS_R, "MAIL" ) ;
-
- if( !never_have_flag ) {
- frame( FVPFLAGS_L, FVPFLAGS_B, FVPFLAGS_R, FVPFLAGS_T,
- ramp0, ramp1, FRAMEW ) ;
- title( VPFLAGS_L, VPFLAGS_B, VPFLAGS_R, "FLAG" ) ;
- }
- }
-
- if( db_base ) frontbuffer(0);
- show_score();
- show_lives();
- show_level();
- show_players();
- #endif /* !defined( NETDEBUGGER ) */
- }
-
-
- static void frame(
- float x01,
- float y01,
- float x02,
- float y02,
- Colorindex c0,
- Colorindex c1,
- float w
- )
- {
- bgnpolygon() ;
- color(c0);
- vertex2f(x01-w,y01-w);
- color(c0);
- vertex2f(x01-w,y02+w);
- color(c1);
- vertex2f(x01 ,y02 );
- color(c1);
- vertex2f(x01 ,y01 );
- endpolygon() ;
- bgnpolygon() ;
- color(c0);
- vertex2f(x01-w,y02+w);
- color(c0);
- vertex2f(x02+w,y02+w);
- color(c1);
- vertex2f(x02 ,y02 );
- color(c1);
- vertex2f(x01 ,y02 );
- endpolygon() ;
- bgnpolygon() ;
- color(c1);
- vertex2f(x02 ,y01 );
- color(c1);
- vertex2f(x02 ,y02 );
- color(c0);
- vertex2f(x02+w,y02+w);
- color(c0);
- vertex2f(x02+w,y01-w);
- endpolygon() ;
- bgnpolygon() ;
- color(c1);
- vertex2f(x01 ,y01 );
- color(c1);
- vertex2f(x02 ,y01 );
- color(c0);
- vertex2f(x02+w,y01-w);
- color(c0);
- vertex2f(x01-w,y01-w);
- endpolygon() ;
- }
-
-
-
- void show_mine_status( void )
- {
- if( !view_only ) {
- if( db_base ) frontbuffer(1);
- if( mine_left ) {
- color( green ) ;
- }
- else if( perm_mine ) {
- color( red ) ;
- }
- else {
- color( yellow ) ;
- }
- sboxf( FVPMINES_L, FVPMINES_B, FVPMINES_R, FVPMINES_T ) ;
- if( db_base ) frontbuffer(0);
- }
- }
-
-
-
- void show_flag_status( void )
- {
- if( !solo && !view_only ) {
- if( db_base ) frontbuffer(1);
- if( HAS_RED_FLAG( player[SELF] ) ) {
- color( red ) ;
- }
- else if( HAS_BLUE_FLAG( player[SELF] ) ) {
- color( blue ) ;
- }
- else {
- color( black ) ;
- }
- sboxf( FVPFLAGS_L, FVPFLAGS_B, FVPFLAGS_R, FVPFLAGS_T ) ;
- if( db_base ) frontbuffer(0);
- }
- }
-
-
-
- void show_heading( void )
- {
- #if !defined( NETDEBUGGER )
- int i ;
- int value ;
-
- value = player[SELF].head * 10.f ;
-
- color( black );
- sboxf( FVPHEAD_L, FVPHEAD_B, FVPHEAD_R, FVPHEAD_T ) ;
- color( yellow );
- pushmatrix() ;
- translate( FVPHEAD_L, FVPHEAD_B, 0.f ) ;
- scale( digit_sx, digit_sy, 0.f ) ;
- translate( 4 * 12.f + 5.f, 5.f, 0.f ) ;
- color( black ) ;
- callobj( digit[value%10][0] ) ;
- color( yellow ) ;
- callobj( digit[value%10][1] ) ;
- value /= 10 ;
- translate( -12.f, 0.f, 0.f ) ;
- bgnline() ;
- vertex2f( 4.f, 0.f ) ;
- vertex2f( 5.f, 0.f ) ;
- endline() ;
- translate( -12.f, 0.f, 0.f ) ;
- for( i = 0 ; i < 3 ; i++ ) {
- color( black ) ;
- callobj( digit[value%10][0] ) ;
- color( yellow ) ;
- callobj( digit[value%10][1] ) ;
- value /= 10 ;
- translate( -12.f, 0.f, 0.f ) ;
- }
- popmatrix() ;
- #endif /* !defined( NETDEBUGGER ) */
- }
-
-
-
- static void show_number(
- int value,
- int places,
- float x,
- float y,
- Colorindex bg,
- Colorindex fg
- )
- {
- #if !defined( NETDEBUGGER )
- int i ;
-
- pushmatrix() ;
- translate( x, y, 0.f ) ;
- scale( digit_sx, digit_sy, 0.f ) ;
- translate( 5.f + ( places - 1 ) * 12.f, 5.f, 0.f ) ;
- for( i = 0 ; i < places ; i++ ) {
- color( bg ) ;
- callobj( digit[value%10][0] ) ;
- color( fg ) ;
- callobj( digit[value%10][1] ) ;
- value /= 10 ;
- translate( -12.f, 0.f, 0.f ) ;
- }
- popmatrix() ;
- #endif /* !defined( NETDEBUGGER ) */
- }
-
-
-
- void show_score( void )
- {
- if( db_base ) frontbuffer( 1 ) ;
- show_something( FVPSCORE_L, FVPSCORE_B, FVPSCORE_R, FVPSCORE_T,
- _ABS( player[SELF].score ), 5,
- black, ( ( player[SELF].score >= 0 ) ? yellow : red ) ) ;
- if( db_base ) frontbuffer( 0 ) ;
- }
-
-
-
- static void show_something(
- float l,
- float b,
- float r,
- float t,
- int value,
- int places,
- Colorindex bg,
- Colorindex fg
- )
- {
- color( black );
- sboxf( l, b, r, t ) ;
- show_number( value, places, l, b, bg, fg ) ;
- }
-
-
-
- void show_level( void )
- {
- if( db_base ) frontbuffer(1);
- show_something( FVPLEVEL_L, FVPLEVEL_B, FVPLEVEL_R, FVPLEVEL_T,
- level, 3, black, yellow ) ;
- if( db_base ) frontbuffer(0);
- }
-
-
-
- void show_players( void )
- {
- if( db_base ) frontbuffer(1);
- show_something( FVPNOPLY_L, FVPNOPLY_B, FVPNOPLY_R, FVPNOPLY_T,
- number_players, 2, black, yellow ) ;
- if( db_base ) frontbuffer(0);
- }
-
-
-
- void post_new_message(
- int count,
- int vocal,
- char *fmt,
- ...
- )
- {
- #if !defined( NETDEBUGGER )
- va_list args ;
- int nc_seen ;
- int i ;
-
- va_start( args, fmt ) ;
- vsprintf( msgs, fmt, args ) ;
-
- nc_seen = (int)( VPMESGS_R - VPMESGS_L ) / (int)char_width ;
-
- if( strlen( msgs ) > nc_seen ) {
- for( i = nc_seen ; i > 0 && msgs[i] != ' ' ; )
- i-- ;
- if( i > 0 && strlen( msgs+i ) <= nc_seen ) {
- bulletin_line = ( bulletin_line + max_msg_lines - 1 )
- % max_msg_lines ;
- strncpy( bulletin[bulletin_line], msgs, i ) ;
- bulletin[bulletin_line][i] = '\0' ;
- bulletin_color[bulletin_line] = current_bulletin_color ;
- }
- else {
- i = nc_seen ;
- bulletin_line = ( bulletin_line + max_msg_lines - 1 )
- % max_msg_lines ;
- strncpy( bulletin[bulletin_line], msgs, i ) ;
- bulletin[bulletin_line][i] = '\0' ;
- bulletin_color[bulletin_line] = current_bulletin_color ;
- }
- bulletin_line = ( bulletin_line + max_msg_lines - 1 )
- % max_msg_lines ;
- strncpy( bulletin[bulletin_line], &msgs[i], POST_MSG_SIZE ) ;
- bulletin_color[bulletin_line] = current_bulletin_color ;
- msg_redraw = 1 ;
- }
- else {
- if( strcmp( msgs, bulletin[bulletin_line] ) ) {
- bulletin_line = ( bulletin_line + max_msg_lines - 1 )
- % max_msg_lines ;
- strncpy( bulletin[bulletin_line], msgs, POST_MSG_SIZE ) ;
- bulletin_color[bulletin_line] = current_bulletin_color ;
- msg_redraw = 1 ;
- }
- }
- current_bulletin_color = green ;
-
- msg_count = ( count == 0 ) ? POST_MSG_DURATION : count ;
- need_to_show_msgs = TRUE ;
- need_to_show_msgs_vocal = vocal ;
- #else
- va_list args ;
- struct BzNotice note ;
-
- va_start( args, fmt ) ;
- print_to_net_debugger( fmt, args ) ;
- #endif /* !defined( NETDEBUGGER ) */
- va_end( args ) ;
- }
-
-
-
- void print_to_net_debugger(
- char *fmt,
- va_list args
- )
- {
- struct BzNotice note ;
- int i ;
-
- vsprintf( msgs, fmt, args ) ;
- i = strlen( msgs ) ;
- if( i > sizeof( msgs ) ) {
- msgs[sizeof(msgs)-1] = '\0' ;
- }
- else if( msgs[i-1] == '\n' ) {
- msgs[i-1] = '\0' ;
- }
- note.bz_id = BZMSG ;
- note.id = player[SELF].id ;
- strncpy( note.out_message, msgs, MAIL_MSG_SIZE ) ;
- send_out( ¬e, sizeof( note ) ) ;
- }
-
-
-
- void show_msgs(
- int vocal,
- int redraw
- )
- {
- unsigned int i ;
- unsigned int n ;
- float x, y ;
-
- if( redraw ) {
- if( db_base ) frontbuffer( 1 ) ;
- color( black ) ;
- sboxf( FVPMESGS_L, FVPMESGS_B, FVPMESGS_R, FVPMESGS_T ) ;
- x = FVPMESGS_L + char_width / 2.f ;
- y = FVPMESGS_B + ( FVPMESGS_T - FVPMESGS_B -
- ( max_msg_lines - .33f ) * char_height ) / 2.f ;
- for( i = 0 ; i < max_msg_lines ; i++ ) {
- n = ( bulletin_line + i ) % max_msg_lines ;
- color( bulletin_color[n] ) ;
- cmov2( x, y ) ;
- charstr( bulletin[n] ) ;
- y+= char_height ;
- }
- if( db_base ) frontbuffer(0) ;
- }
-
- if( vocal ) ringbell() ;
- }
-
-
-
- void show_lives( void )
- {
- if( db_base ) frontbuffer(1);
- show_something( FVPLIVES_L, FVPLIVES_B, FVPLIVES_R, FVPLIVES_T,
- lives, 3, black, yellow ) ;
- if( db_base ) frontbuffer(0);
- }
-
-
-
- static void show_speed_util(
- float track,
- float l,
- float b,
- float r,
- float t
- )
- {
- float s ;
-
- if( !guiding ) {
- if( track > 0.0f ) {
- color( green ) ;
- s = track ;
- }
- else if( track < 0.0f ) {
- color( red ) ;
- s = -track ;
- }
- else {
- color( black ) ;
- s = 0.0f ;
- }
- s = b + ( t - b ) * ( s / top_speed ) ;
- sboxf( l, b, r, s ) ;
- color( black ) ;
- sboxf( l, s, r, t ) ;
- }
- else {
- color( green );
- sboxf( l, b, r, t ) ;
- }
- }
-
-
-
- void show_speed( void )
- {
- show_speed_util( right_track, FVPRIGHT_L, FVPRIGHT_B, FVPRIGHT_R,
- FVPRIGHT_T ) ;
- show_speed_util( left_track, FVPLEFTT_L, FVPLEFTT_B, FVPLEFTT_R,
- FVPLEFTT_T ) ;
- }
-
-
-
- void show_gun_status(
- int n
- )
- {
- char *s ;
- int l ;
- float x ;
- float y ;
-
- if( IS_DEAD( player[SELF] ) ) {
- if( sending_msg != SENDING_NO_MAIL ) {
- n = MAIL_MSG_SIZE - strlen( mail.out_message ) ;
- s = "MAILING" ;
- l = 7 ;
- }
- else {
- n = player[SELF].status - MIN_DEAD_STATUS + 1 ;
- s = "DEAD" ;
- l = 4 ;
- }
- }
- else {
- l = 7 ;
- if( view_only ) {
- s = "VIEWING" ;
- n = 1 ;
- }
- else {
- s = "LOADING" ;
- }
- }
-
- if( n > 0 ) {
- x = ( FVPLOADM_R - FVPLOADM_L - l * char_width ) * 0.5f ;
- y = ( FVPLOADM_T - FVPLOADM_B - .6f * char_height ) * 0.5f ;
- show_something( FVPREADY_L, FVPREADY_B, FVPREADY_R, FVPREADY_T,
- n, 5, black, yellow ) ;
- color( ( ( n / 5 ) % 2 ) ? red : black ) ;
- sboxf( FVPLOADM_L, FVPLOADM_B, FVPLOADM_R, FVPLOADM_T ) ;
- cmov2( FVPLOADM_L + x, FVPLOADM_B + y ) ;
- color( ( ( n / 5 ) % 2 ) ? black : red ) ;
- charstr( s ) ;
- }
- else {
- x = ( FVPLOADM_R - FVPLOADM_L - 5.f * char_width ) * 0.5f ;
- y = ( FVPLOADM_T - FVPLOADM_B - .6f * char_height ) * 0.5f ;
- color( green ) ;
- sboxf( FVPLOADM_L, FVPLOADM_B, FVPLOADM_R, FVPLOADM_T ) ;
- sboxf( FVPREADY_L, FVPREADY_B, FVPREADY_R, FVPREADY_T ) ;
- cmov2( FVPLOADM_L + x, FVPLOADM_B + y ) ;
- color( black ) ;
- charstr( "READY" ) ;
- cmov2( FVPREADY_L + x, FVPREADY_B + y ) ;
- charstr( "READY" ) ;
- }
- }
-
-
-
- static void title(
- int left,
- int bottom,
- int right,
- char *s
- )
- {
- float x;
-
- x = (float)( left + right - strlen(s)*char_width ) / 2.f ;
- color( black ) ;
- cmov2( x+2.f, bottom-9.f-17.f) ;
- charstr( s ) ;
- color( ramp3 ) ;
- cmov2( x, bottom-9.f-16.f ) ;
- charstr( s ) ;
- }
-
-
-
- void show_out_message( void )
- {
- int nc_seen ;
- int nc_total ;
-
- if( !solo && !view_only ) {
- nc_seen = (int)( VPOUTMS_R - VPOUTMS_L ) / (int)char_width - 1 ;
- if( db_base ) frontbuffer( 1 ) ;
- color( black ) ;
- sboxf( FVPOUTMS_L, FVPOUTMS_B, FVPOUTMS_R, FVPOUTMS_T ) ;
- if( sending_msg == SENDING_ALL_MAIL ||
- player[SELF].team == NEUTRAL_TEAM ) {
- color( green ) ;
- }
- else if( player[SELF].team == RED_TEAM ) {
- color( red ) ;
- }
- else if( player[SELF].team == BLUE_TEAM ) {
- color( blue ) ;
- }
- else { /* Shouldn't get here! */
- color( green ) ;
- }
- cmov2( FVPOUTMS_L + 3.f, FVPOUTMS_B + 3.f) ;
- if( ( nc_total = strlen( mail.out_message ) ) > nc_seen )
- charstr( &mail.out_message[nc_total-nc_seen] ) ;
- else
- charstr( mail.out_message ) ;
- if( sending_msg != SENDING_NO_MAIL )
- charstr( "_" ) ;
- if( db_base ) frontbuffer( 0 ) ;
- }
- }
-
-
-
-
- void show_zoom_factor( void )
- {
- short l ;
- short r ;
- short b ;
- short t ;
- float xmax ;
- float ymax ;
- char mag_power[5] ;
-
- if( ol_mode > -1 ) {
- reshapeviewport() ;
- getviewport( &l, &r, &b, &t ) ;
- xmax = r - l ;
- ymax = t - b ;
- loadmatrix( id_mat ) ;
- ortho2( 0.f, xmax, 0.f, ymax ) ;
- color( 1 ) ;
- sboxf( 0.f, 0.f, 5.f * char_width, char_height + 4.f ) ;
- color( 2 ) ;
- cmov2( 3.f, 3.f ) ;
- sprintf( mag_power, "X%-3g", zoom_factor ) ;
- charstr( mag_power ) ;
- }
- }
-
-
-
- void drawOverlay( void )
- {
- reshapeviewport() ;
- color( 0 ) ;
- clear() ;
-
- if( ol_mode > -1 ) {
- pushmatrix();
- loadmatrix( id_mat ) ;
- ortho2(-825.f,825.f,-825.f,825.f);
- callobj( radar1 ) ;
- popmatrix();
- show_zoom_factor() ;
- }
-
- if( ol_mode == 1 ) {
- show_pick_tank_instructions() ;
- }
- }
-
-
-
- static void show_pick_tank_instructions( void )
- {
- short l ;
- short r ;
- short b ;
- short t ;
- float x ;
- float y ;
- float xmax ;
- float ymax ;
-
- reshapeviewport() ;
- getviewport( &l, &r, &b, &t ) ;
- xmax = r - l ;
- ymax = t - b ;
- loadmatrix( id_mat ) ;
- ortho2( 0.f, xmax, 0.f, ymax ) ;
- y = ymax - 60.f ;
- x = ( xmax - 25.f * char_width ) / 2.f ;
- cmov2( x, y ) ;
- color( 2 ) ;
-
- if( picking_tank ) {
- charstr("Hit the following keys to");
- cmov2(x, (y -= char_height)) ;
- if( !init_wait )
- charstr("change tanks:");
- else
- charstr( "select your tank:" ) ;
- cmov2( x, ( y -= char_height*1.25f ) ) ;
- charstr( "1 regular 50 pts" ) ;
- cmov2( x, ( y -= char_height) ) ;
- charstr( "2 super 75 pts" ) ;
- cmov2( x, ( y -= char_height) ) ;
- charstr( "3 stealth 100 pts" ) ;
- cmov2( x, ( y -= char_height) ) ;
- charstr( "4 runner 125 pts" ) ;
- }
- else if( !solo ) {
- charstr(" Available options:");
- cmov2(x, (y -= char_height*1.25f)) ;
- if( player[SELF].team == NEUTRAL_TEAM ) {
- charstr(" b : join blue team");
- cmov2(x, (y -= char_height)) ;
- }
- charstr(" c : change tanks");
- cmov2(x, (y -= char_height)) ;
- charstr(" m : mail message");
- cmov2(x, (y -= char_height)) ;
- if( player[SELF].team == NEUTRAL_TEAM ) {
- charstr(" r : join red team");
- cmov2(x, (y -= char_height)) ;
- }
- charstr(" t : mail team message");
- }
- }
-
-
-
- void drawBaseCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data
- )
- {
- GLXwinset( XtDisplay(w), ((GlxDrawCallbackStruct *)call_data)->window ) ;
- redraw_base_screen() ;
- }
-
-
-
- void drawRadarCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data
- )
- {
- GLXwinset( XtDisplay(w), ((GlxDrawCallbackStruct *)call_data)->window ) ;
- if( init_wait ) {
- reshapeviewport() ;
- color( black ) ;
- clear() ;
- }
- else {
- radar_view() ;
- }
- gflush() ;
- swapbuffers() ;
- GLXwinset( display, base_window ) ;
- }
-
-
-
- void initBaseGlCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- #if !defined( NETDEBUGGER )
- int n ;
- Dimension wi, hi ;
- Dimension x, y ;
-
- base_window = ((GlxDrawCallbackStruct *)call_data)->window ;
- GLXwinset( XtDisplay(w), base_window ) ;
-
- n = 0 ;
- XtSetArg( wargs[n], XmNwidth, &wi ) ; n++ ;
- XtSetArg( wargs[n], XmNheight, &hi ) ; n++ ;
- XtSetArg( wargs[n], XmNx, &x ) ; n++ ;
- XtSetArg( wargs[n], XmNy, &y ) ; n++ ;
- XtGetValues( w, wargs, n ) ;
-
- zbuffer( FALSE ) ;
- subpixel( TRUE ) ;
- mmode( MVIEWING ) ;
- loadmatrix( id_mat ) ;
- concave( FALSE ) ;
- backface( FALSE ) ;
- init_color( BASE_VIEW_MAP, w ) ;
- indicate_map_order( base_window, BASE_VIEW_MAP ) ;
-
- current_bulletin_color = green ;
- teamColor[NEUTRAL_TEAM] = green ;
- teamColor[RED_TEAM] = red ;
- teamColor[BLUE_TEAM] = blue ;
-
- make_all() ;
-
- init_var() ;
- init_bulletin() ;
- #endif /* !defined( NETDEBUGGER ) */
- }
-
-
-
- void initRadarGlCB(
- Widget w,
- XtPointer client_data,
- XtPointer call_data )
- {
- #if !defined( NETDEBUGGER )
- int n ;
- Dimension x, y ;
- Dimension wi, hi ;
-
- radar_window = ((GlxDrawCallbackStruct *)call_data)->window ;
- GLXwinset( XtDisplay(w), radar_window ) ;
-
- n = 0 ;
- XtSetArg( wargs[n], XmNwidth, &wi ) ; n++ ;
- XtSetArg( wargs[n], XmNheight, &hi ) ; n++ ;
- XtSetArg( wargs[n], XmNx, &x ) ; n++ ;
- XtSetArg( wargs[n], XmNy, &y ) ; n++ ;
- XtSetArg( wargs[n], ( use_pups ) ? GlxNpopupWindow : GlxNoverlayWindow,
- &radar_ol_window ); n++ ;
- XtGetValues( w, wargs, n ) ;
-
- zbuffer( FALSE ) ;
- subpixel( TRUE ) ;
- shademodel( FLAT ) ;
- mmode( MVIEWING ) ;
- loadmatrix( id_mat ) ;
- concave( FALSE ) ;
- backface( FALSE ) ;
- init_color( RADAR_VIEW_MAP, w ) ;
- indicate_map_order( radar_window, RADAR_VIEW_MAP ) ;
-
- GLXwinset( XtDisplay(w), radar_ol_window ) ;
- init_overlay_color( w ) ;
- make_radar() ;
- #endif /* !defined( NETDEBUGGER ) */
- }
-
-
-
- /*------------------------------------------------------------------------------
- * Set the bulletin color for the next posted message.
- *----------------------------------------------------------------------------*/
- void set_bulletin_color(
- Colorindex n
- )
- {
- current_bulletin_color = n ;
- }
-
-
-
- float radar_view_angle[3][2] = {
- { -375., 750. },
- { 0., 0. },
- { 375., 750. }
- } ;
- float binocular_radar_view_angle[3][2] = {
- { -375., 750. },
- { 0., 0. },
- { 375., 750. }
- } ;
- static float radar_north[4][2] = {
- { -25., 650. },
- { -25., 700. },
- { 25., 650. },
- { 25., 700. },
- } ;
-
-
- void radar_view( void )
- {
- unsigned i;
-
- reshapeviewport() ;
-
- loadmatrix( id_mat ) ;
- pushmatrix();
- ortho2( -1650.f, 1650.f, -1650.f, 1650.f ) ;
- scale( zoom_factor, zoom_factor, 0.f ) ;
-
- color( black ) ;
- clear() ;
- font( 1 ) ;
-
- if( zoom_factor > 2.f ) {
- color( yellow ) ;
- rect( -5.f, -10.f, 5.f, 10.f ) ;
- }
-
- rot( player[SELF].head, 'z' );
- translate( -player[SELF].x, -player[SELF].y, 0.f ) ;
- color( ground_color ) ;
- callobj( border ) ;
- if( show_flags ) {
- callobj( flag_homes ) ;
- if( !red_flag_held ) {
- color( red ) ;
- pnt2( flag_x[RED_FLAG], flag_y[RED_FLAG] ) ;
- }
- if( !blue_flag_held ) {
- color( blue ) ;
- pnt2( flag_x[BLUE_FLAG], flag_y[BLUE_FLAG] ) ;
- }
- }
-
- for(i = ENEMY ; i < number_players ; i++ ) {
- color( teamColor[player[i].team] ) ;
- if( IS_ALIVE( player[i] ) ) {
- if( !IS_STEALTH_TANK( player[i] ) ) {
- pushmatrix() ;
- translate( player[i].x, player[i].y, 0.f ) ;
- rot( -player[i].head, 'z' ) ;
- rectf( -5.f, -10.f, 5.f, 10.f ) ;
- popmatrix() ;
- }
- }
- else {
- pnt2(player[i].x,player[i].y);
- }
- }
-
- color( white ) ;
- for( i = SELF ; i < number_players ; i++ ) {
- if( player[i].msl_status > 0 ) {
- cmov2( player[i].msl_x, player[i].msl_y ) ;
- charstr("+");
- }
- }
-
- color( ground_color ) ;
- for( i = CONES ; i < TOTALOBSTS ; i++ ) {
- rectf( obst_x[i]-10.f, obst_y[i]-10.f, obst_x[i]+10.f, obst_y[i]+10.f );
- }
-
- if( mine_status > 0 ) {
- color( yellow );
- circ( mine_x, mine_y, 15.f ) ;
- if( !perm_mine )
- circ( mine_x, mine_y, DET_MINE_RADIUS ) ;
- }
-
- font( 0 ) ;
- popmatrix() ;
-
- ortho2(-825.f,825.f,-825.f,825.f) ;
-
- color( yellow );
- bgnline() ;
- if( binoculars ) {
- v2f( binocular_radar_view_angle[0] ) ;
- v2f( binocular_radar_view_angle[1] ) ;
- v2f( binocular_radar_view_angle[2] ) ;
- }
- else {
- v2f( radar_view_angle[0] ) ;
- v2f( radar_view_angle[1] ) ;
- v2f( radar_view_angle[2] ) ;
- }
- endline() ;
-
- rot( player[SELF].head, 'z' );
-
- color( yellow );
- bgnline() ;
- v2f( radar_north[0] ) ;
- v2f( radar_north[1] ) ;
- v2f( radar_north[2] ) ;
- v2f( radar_north[3] ) ;
- endline() ;
- }
-
-
-
- static void init_bulletin( void )
- {
- max_msg_lines = (int)( VPMESGS_T - VPMESGS_B ) / (int)char_height ;
-
- if( ( bulletin_color = (Colorindex *)
- calloc( max_msg_lines, sizeof( Colorindex ) ) ) == NULL ) {
- fprintf( stderr, "%s: out of memory\n", basename ) ;
- end_program( 1 ) ;
- }
-
- if( ( bulletin = (BulletinLine *)
- calloc( max_msg_lines, sizeof( BulletinLine ) ) ) == NULL ) {
- fprintf( stderr, "%s: out of memory\n", basename ) ;
- end_program( 1 ) ;
- }
- }
-